package org.ch02.job.test05;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

/**
 * @author XCH
 * @date 2025 - 03 - 17
 */
public class MainTest {
    public static void main(String[] args) {
        Class<?> clazz = String.class;
        Method[] methods = clazz.getDeclaredMethods() ;
        System.out.println("方法的个数：" + methods.length);
        for (Method method : methods) {
            String modifier = Modifier.toString(method.getModifiers());
            String returnType = method.getReturnType().getName();
            String methodName = method.getName();
            StringBuilder params = new StringBuilder();
            Class<?>[] paramTypes = method.getParameterTypes();
            for (int i = 0; i < paramTypes.length; i++) {
                params.append(paramTypes[i].getSimpleName()).append(",");
                if (i < paramTypes.length - 1) {
                    params.append(", ");
                }
            }
            System.out.println(modifier + " " + returnType + " " + methodName + "(" + params + ")");
        }
    }
}
